home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / examples / benchmark2.ys < prev    next >
Encoding:
Text File  |  2002-03-13  |  2.0 KB  |  71 lines

  1.  
  2.  
  3. Use("testers.ys");
  4.  
  5.  
  6. DoNext(_string) <--
  7. [
  8.  NextTest("<font color=0000ff>" : string : "</font>");
  9.  NewLine();
  10. ];
  11.  
  12. Echo({"<HTML><BODY BGCOLOR=\"ffffff\"><PRE><font size=4>"});
  13.  
  14. Echo({"An assorted selection of example calculations using Yacas"});
  15.  
  16. StartTests();
  17.  
  18. /*
  19. */
  20.  
  21. DoNext("Show that Integrate(-Pi,Pi) (Sin(n*x)*Cos(m*x)) is Pi*Delta(n,m)");
  22.  
  23. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Sin(x)*Sin(2*x)) ));
  24. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Sin(2*x)*Sin(2*x)) ));
  25. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Sin(5*x)*Sin(5*x)) ));
  26.  
  27. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Cos(x)*Cos(2*x)) ));
  28. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Cos(2*x)*Cos(2*x)) ));
  29. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Cos(5*x)*Cos(5*x)) ));
  30.  
  31. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Sin(x)*Cos(2*x)) ));
  32. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Sin(2*x)*Cos(2*x)) ));
  33. BenchShow(Simplify(Integrate(x,-Pi,Pi) (Sin(5*x)*Cos(5*x)) ));
  34.  
  35.  
  36. DoNext("Get the first 5 coefficients of the Fourier series of x^2
  37. on the domain -Pi to Pi. This should be (1/Pi)*Sum(n,0,4)a_n * Cos(n*x)");
  38.  
  39. BenchShow(Fourier(_n,_f) <-- (1/(Pi))*Integrate(x,-Pi,Pi)(f*Cos(n*x)) );
  40. BenchShow(TableForm(Simplify(Table(Fourier(n,x^2),n,0,5,1))));
  41.  
  42. DoNext("Check that f:=x*Exp(-x/2) is a solution to the equation H(f)=E f
  43. where E is a constant and H is D(x)D(x)f + f/x");
  44.  
  45. BenchCall(H(f):=(Deriv(x)Deriv(x)f) + f/x);
  46. BenchCall(f:=x*Exp(-x/2));
  47. BenchCall(res:=H(f));
  48. BenchCall(PrettyForm(Simplify(res)));
  49. BenchCall(PrettyForm(Simplify(res/f)));
  50.  
  51.  
  52. DoNext("Show that the first few terms of the Taylor series expansion
  53. of Sin(x) and Cos(x-Pi/2) are the same");
  54. BenchCall(ans1:=Taylor(x,0,8)Sin(x));
  55. BenchCall(PrettyForm(ans1));
  56. BenchCall(ans2:=Taylor(x,0,8)Cos(x-Pi/2));
  57. BenchCall(PrettyForm(ans2));
  58. BenchShow(ans1-ans2);
  59.  
  60.  
  61. DoNext("Determine a polynomial that goes through the points
  62. (x,y) = { (-2,4), (1,1), (3,9) } and show that it is in fact x^2");
  63.  
  64. BenchCall(ans:=LagrangeInterpolant({-2,1,3},{4,1,9},x));
  65. BenchCall(PrettyForm(ans));
  66. BenchCall(PrettyForm(Simplify(ans)));
  67.  
  68. Echo({curline," examples shown"});
  69.  
  70. Echo({"</FONT></PRE></BODY></HTML>"});
  71.